/**
 * 
 */
package com.ge.healthcare.autosc.common.util;

/**
 * @author 212042764
 *
 */
/*
 * $Id: FTRLog.java,v 1.1 2010/09/24 19:56:24 navdeep_mahajan Exp $
 *
 * Copyright (C) 2006 General Electric Company. All Rights Reserved.
 *
 * This software is the confidential and proprietary information of the
 * General Electric Company (GE). You shall not disclose this software and
 * shall use it only in accordance with the terms of the license agreement
 * you entered into with GE.
 *
 * GE MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
 * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 * PURPOSE, OR NON-INFRINGEMENT. GE SHALL NOT BE LIABLE FOR ANY DAMAGES
 * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING, OR DISTRIBUTING
 * THIS SOFTWARE OR ITS DERIVATIVES.
 */

import com.ge.med.service.eds.fault.FaultBOFactory;
import com.ge.med.service.eds.fault.FaultInfo;
import com.ge.med.service.eds.fault.IFault;

/**
 * Purpose:
 * <ul>
 * <li>Used for Fault Tracking</li>
 * </ul>
 * 
 * @author Navdeep Mahajan
 * @copyright (C) 2006 The General Electric Company
 */
public class FTRLog {

	/**
	 * Japan RFS Program Code
	 */
	public static final String JRFS = "JRFS";

	/**
	 * No need to instantiate the class. All methods are static
	 */
	private FTRLog() {
		// do nothing
	}

	/**
	 * Fault condition logging is utilizing the FTR API provided by EDS. It
	 * shall be used in the catch statement of the program.
	 * 
	 * @param throwable
	 *            The exception caught
	 */
	public static void log(String programCode, Throwable throwable) {
		log(programCode, null, null, throwable);
	}

	/**
	 * Fault condition logging is utilizing the FTR API provided by EDS. It
	 * shall be used in the catch statement of the program.
	 * 
	 * @param throwable
	 *            The exception caught
	 */
	public static void log(String programCode, String feature,
			String subFeature, Throwable throwable) {
		// faultName: java exception name
		// programCode: ISD
		// pMessage: exception.getMessage()
		FaultInfo faultInfo = new FaultInfo(throwable.getClass().getName(),
				programCode, feature, subFeature, throwable.getMessage());
		faultInfo.setStackTrace(throwable); // set any other fields as
		// applicable
		IFault faultBO = FaultBOFactory.getInstance().getFaultBO(); // get
		// FaultBO
		faultBO.insertFault(faultInfo); // insert the fault.
	}

}
